<include file="Public/head"/>
<link type="text/css" rel="stylesheet" href="{:get_style_cdnurl()}paimai/yunying/plugin/select2/select2.css" />
<script src="{:get_style_cdnurl()}paimai/yunying/plugin/select2/select2.js" type="text/javascript"></script>
<script src="{:get_style_cdnurl()}paimai/yunying/js/city.js" type="text/javascript"></script>
<style>
    .xuanzhe {margin-top: 0px;}
    .xuanzhe ul li{margin-bottom: 5px;}
    .xuanzhe ul li span {text-align: left;}
    .xuanzhe ul li .menDao1{width:300px;}
    .xuanzhe ul li .menDao1 a{display:block;background:#cecece;color:#303030;float:left;width:36px; text-align:center;height:20px; line-height:20px; cursor:pointer;}
    .xuanzhe ul li .menDao1 .menHover{ background:#20ab4f;color:#fff;}
    .xuanzhe .lift-truck{width:280px;padding:10px;display:block; background:#e1e1e1;border-radius:5px;margin-left:60px;margin-top:-10px;}
    .xuanzhe .lift-truck #taker_phone,.xuanzhe .lift-truck #taker_sex,.xuanzhe .lift-truck #taker_card,.xuanzhe .lift-truck #take_car_num{width:280px; display:block;height:30px; line-height:30px; text-align:left;}
    .xuanzhe .lift-truck span em{float:left; display:block;width:60px; text-align:right;}
    .yt_total{height:50px;line-height: 50px;width: 60%;border-top:1px solid #ccc;margin: 3% 0 0 3%;text-align:left;}
    .remarks{width: 100%;height: auto; margin-top: 20px; }
    .remarks span{display: block;width: 90px;float: left;line-height: 65px;font-size:14px;}
    .remarks textarea{border: 1px solid #c8c8c8;  float: left;  height: 65px;  padding: 5px;  resize: none;  width: 745px;}
    .chezhu-xinxi table tr td{height:30px;text-align:left;font-size:12px;padding-left:10px;}

    .account{width:90%;float: left;}
    .accountCurrent{background-color: #33CCFF;color:#fff9f9;}
    .account ul{padding: 0px;}
    .account ul li{width: 46%;margin:0;padding:10px 0;border-radius: 5px;border:1px solid #E4E4E4;float: left;}
    .account ul>li:not(:first-child){margin-left: 4%;}
    .account ul li:hover{cursor:pointer;}
    .account ul li div{width: 100%;clear: both;}
    .account ul li span{height:25px;line-height:25px;display: block;width: auto;}
    .account ul li .span_right{text-align: right;width: 25%;}
</style>
<include file="Public/common_header"/>
<div class="mian">
    <include file="Public/sidebar" menu="cjgl.sfcs"/>
    <div class="mianR">
        <h3 class="yonghu"> 基本信息</h3>
        <div class="chezhu-xinxi">
            <div class="xinxi-conter xinxi-conter1" style="background: none;border: none">
                <h4 class="order_no">拍卖单号：<b>{$detail.order_no}</b></h4>
            </div>
            <br/>
            <div class="xinxi-conter xinxi-conter1">
                <h4>车主信息</h4>
                <ul>
                    <li class="clearfix">
                        <em>车主类型</em><em class="name-text">{$detail.owner_type_name}</em>
                        <if condition="$detail.owner_type eq 1">
                            <em>车主姓名</em><em class="name-text">{$detail.seller_name}</em>
                            <else />
                            <em>公司名称</em><em class="name-text">{$detail.seller_name}</em>
                        </if>
                    </li>
                    <li class="clearfix">
                        <if condition="$detail.owner_type eq 1">
                            <em>联系电话</em><em class="name-text">{$detail.phone}</em>
                            <else />
                            <em>联系人姓名</em><em class="name-text">{$detail.contact_person}</em>
                            <em>联系电话</em><em class="name-text">{$detail.phone}</em>
                        </if>
                    </li>
                </ul>
            </div>
            <br/>
            <div class="xinxi-conter xinxi-conter1">
                <h4>车商信息</h4>
                <ul>
                    <li class="clearfix">
                        <em style="width: 250px">名次</em>
                        <em style="width: 25%">车商联系人</em>
                        <em style="width: 25%">联系人电话</em>
                        <em style="width: 25%">车商出价</em>
                    </li>
                    <volist name="rank_data" id="rd">
                        <li class="clearfix">
                            <em style="width: 250px">第{$rd.sort}名</em>
                            <em style="width: 25%">{$rd.dealer_name}</em>
                            <em style="width: 25%">{$rd.contact_mobile}</em>
                            <em style="width: 25%">{$rd.price}</em>
                        </li>
                    </volist>
                </ul>
            </div>
            <br/>
            <div class="xinxi-conter xinxi-conter1">
                <h4>车辆信息（第{$detail.au_times}次拍卖）
                    <a href="/Car/report/car_id/{$detail.car_id}" target="_blank">
                        <span style="float:right;padding-right: 10%;color:#20ab4f;">检测报告</span>
                    </a>
                </h4>
                <ul>
                    <li class="clearfix">
                        <em>车型</em><em class="name-text">{$detail.model}</em>
                        <em>排放标准</em><em class="dian-hua">{$detail.emission}</em>
                    </li>

                    <li class="clearfix">
                        <em>初登日期</em><em class="name-text">{$detail.first_reg_date}</em>
                        <em>颜色</em><em class="dian-hua">{$detail.car_color}</em>
                    </li>
                    <li class="clearfix">
                        <em>表显里程</em><em class="name-text">{$detail.pointer_mileage}万公里</em>
                        <em>车况级别</em><em class="name-text">{$detail.composite_state}{$detail.accident_level}</em>
                    </li>
                    <li class="clearfix">
                        <em>车辆注册地</em><em class="name-text">{$detail.reg_city}</em>
                        <em>车架号</em><em class="name-text">{$detail.vin}</em>
                    </li>
                    <li class="clearfix">
                        <em>过户限制</em><em class="name-text">{$transfer_type[$car_detail['transfer_limit']]}</em>
                        <em>车牌号</em><em class="name-text">{$detail.plate_prefix}{$detail.plate_suffix}</em>
                    </li>
                    <li class="clearfix">
                        <em>渠道来源</em><em class="name-text">
                        <if condition="$car_detail.comefrom neq ''">
                            <?php if(empty($car_detail['comefrom_url'])):?>
                            <?php echo $show_from[$car_detail['comefrom']];?>
                            <?php else: ?>
                            <a href="{$car_detail.comefrom_url}" target="_blank" rel="noreferrer"><?php echo $show_from[$car_detail['comefrom']];?></a>
                            <?php endif;?>
                            <else/>
                            未知
                        </if>
                    </em>
                        <em>所在地</em><em class="name-text">{$detail.location_area_name}</em>
                    </li>
                </ul>
            </div>
            <br/>
            <div class="xinxi-conter xinxi-conter1">
                <h4>拍卖信息</h4>
                <ul>
                    <li class="clearfix">
                        <em>竞拍结束时间</em><em class="name-text">{$detail.bidding_end_time}</em>
                        <em>第一名出价</em><em class="name-text">{$detail.bidding_best_price}</em>
                    </li>
                    <li class="clearfix">
                        <em>保留价</em><em class="name-text">{$detail.reserve_price}元</em>
                        <em>建议价</em><em class="name-text">{$detail.suggest_price}</em>
                    </li>
                </ul>
            </div>
            <br/>
            <div class="xinxi-conter xinxi-conter1">
                <h4>备注信息</h4>
                <ul>
                    <li class="clearfix">
                        <em>确认备注</em><em class="name-text" style="width: 875px;">{$detail.remark}</em>
                    </li>
                </ul>
            </div>
        </div>
        <if condition="$status eq 2">
            <h3 class="yonghu">系统跟踪日志</h3>
            <div class="yonghuText">
                <ul>
                    <volist name="consult_trace_log" id="log" key="k">
                        <li class="{$k%2==0?'xitongBg':''} clearfix">
                            <em class="huShi">{$log.createtime}</em>
                            <em>客服</em>
                            <em>{$log.emp_name}</em>
                            <em>{$log.action}</em>
                            <em class="huShi">{$log.result}</em>
                        </li>
                    </volist>
                </ul>
            </div>
        </if>

        <div class="consultations">
        <h3 class='cha' style="margin: 0">磋商结果</h3>
        <div class="yuyue">
            <span>请选择确认结果：</span>
            <ul>
                <li  class="yuCurrent">磋商成功</li>
                <li  class="">重拍</li>
                <li  class="">继续跟踪</li>
                <li  class="">不卖</li>
            </ul>
        </div>

        <div class="listBox">
            <div class="yuList" style="display: block;">
                <div class="negotiation">
                    <h4>磋商信息</h4>
                    <span><i>当前最高价：</i>{$detail.bidding_best_price_count}元</span>
                    <span><i>第一名加价</i><input type="text" value="" placeholder="请输入加价金额" id="fare" /></span>
                    <span><i>公司补贴</i><input type="text" value="" placeholder="请输入补贴金额" id="subsidy" /></span>
                    <div class="clear"></div>
                    <em>拍卖最高价（<i class="auction-price"></i>元）= 当前最高价（<i class="cuur-price">{$detail.bidding_best_price_count}</i>元）+ 第一名加价（<i class="fare-price">0.00</i>元）</em>
                </div>
                <div class="negotiation negotiation1">
                    <h4>结算信息</h4>
                    <em>车主成交价（<i class="auction-price1"></i>元）= 拍卖最高价（<i class="cuur-price1">{$detail.bidding_best_price_count}</i>元）+ 公司补贴（<i class="subsidy-price">0.00</i>元）</em>
                    <em>车商合手价（<i class="auction-price2"></i>元）= 拍卖最高价（<i class="cuur-price2">{$detail.bidding_best_price_count}</i>元）+ 交易服务费（<i class="deal-price">0.00</i>元）+  交付服务费（<i class="deliver-price">{$detail.transfer_fee}</i>元）</em>
                </div>
                <input type="hidden" name="car_source" id="car_source" value="{$detail.car_source}">
                <if condition="$detail.car_source eq 2">
                    <div class="negotiation negotiation1">
                        <h4>签约信息</h4>
                        <ul>
                            <li class="clearfix">
                                <span>服务方式</span>
                                <span class="menDao">
                                    <a href="javascript:void(0);" onclick="$('#service_method').val(3);" class="menHover">到店</a>
                                    <a href="javascript:void(0);" onclick="$('#service_method').val(2);" >上门</a>
                                </span>
                                <input type="hidden" id="service_method" name="service_method" value="3">
                            </li>
                            <li class="clearfix">
                                <span id="appointment">预约门店</span>
                                <div class="store">
                                    <div class="detailed" style="display:block;">
                                        <select id="reserve_store" name="reserve_store" >
                                            <option value="0">请选择门店</option>
                                            <?php foreach($stores as $key=>$vs):?>
                                            <option value="{$key}">{$vs}</option>
                                            <?php endforeach;?>
                                        </select>
                                    </div>
                                    <div class="detailed" style="display:none;">
                                        <script>var addr = new AddressCom("reserve");</script><input type="hidden" id="province_328412" name="province_reserve" value=""><input type="hidden" id="city_328412" name="city_reserve" value=""><input type="hidden" id="area_328412" name="area_reserve" value="">
                                        <input id="reserve_address" name="reserve_address" type="text" value="" placeholder="详细地址" class="xiangDi">
                                    </div>
                                </div>
                            </li>
                            <li class="clearfix">
                                <span>预约时间</span>
                                <input type="text" name="reserve_time" value="请选择预约时间" id="reserve_time" class="xiaci" readonly/>
                            </li>
                        </ul>
                    </div>
                    <else />
                    <div class="negotiation negotiation1">
                        <h4>打款信息</h4>
                        <ul>
                            <li class="clearfix">
                                <span style="width: 60px;">打款账号</span>
                                <input type="hidden" name="account_id" id="account_id" value="">
                                <input type="hidden" name="bank_name" id="bank_name" value="">
                                <input type="hidden" name="card_no" id="card_no" value="">
                                <input type="hidden" name="account_name" id="account_name" value="">
                                <div class="account">
                                    <ul class="clearfix">
                                        <volist name="fours_bank_account" id="fba" key="k">
                                            <li class="clearfix" data-id="{$fba.id}" data-bank-name="{$fba.bank_name}" data-card-no="{$fba.card_no}" data-account-name="{$fba.account_name}">
                                                <if condition="$fours_bank_account_total gt 1">
                                                    <div>
                                                        <span class="span_right">打款帐号{$k}&nbsp;&nbsp;</span>
                                                    </div>
                                                </if>
                                                <div>
                                                    <span class="span_right">开户银行：</span>
                                                    <span style="width: auto;">{$fba.bank_name}</span>
                                                </div>
                                                <div>
                                                    <span class="span_right">银行账号：</span>
                                                    <span style="width: auto;">{$fba.card_no}</span>
                                                </div>
                                                <div>
                                                    <span class="span_right">账户名：</span>
                                                    <span style="width: auto;">{$fba.account_name}</span>
                                                </div>
                                            </li>
                                        </volist>
                                    </ul>
                                </div>
                            </li>
                        </ul>
                    </div>
                </if>
                <div class="negotiation2">
                    <span>备注</span>
                    <textarea id="consult_remark" class="consult_remark" name="consult_remark"></textarea>
                </div>
                <div class="yongBtn">
                    <input type="submit" value="确认" class="queding consult"/>
                    <input class="quxiao" type="submit" value="返回" onclick="history.back();">
                </div>
            </div>
            <div class="yuList" style="display: none;">
                <div class="shop_details" style="margin-top:15px;">
                    <ul>
                        <li>
                            <span>保留价</span>
                            <em><input id="compensate" type="text" name="compensate" value="{$detail.reserve_price_count}"> 元</em>
                        </li>
                        <li><span>过户限制</span>
                            <select class="limit-change">
                                <?php foreach(C('TRANSFER_LIMIT') as $tk=>$val):?>
                                <option <?php echo $car_detail['transfer_limit']==$tk ? 'selected' : '' ;?>  value="{$tk}">{$val}</option>
                                <?php endforeach;?>
                            </select>
                        </li>
                        <li>
                            <span>备注</span>
                            <textarea id="reauction_remark" class="remarks_text"></textarea>
                        </li>
                    </ul>
                </div>
                <div class="yongBtn">
                    <input type="submit" value="确认" class="queding reauction"/>
                    <input class="quxiao" type="submit" value="返回" onclick="history.back();">
                </div>
            </div>
            <div class="yuList" style="display: none;">
                <div class="xuanzhe1" style="background: none;border:none;margin:0;">
                    <ul>
                        <li class="genBtn1 clearfix">
                            <span class="gencuur"><font>电话无人接听</font><input name="trace_reason" value="电话无人接听" type="checkbox"></span>
                            <span class="gencuur"><font>电话停机或关机</font><input name="trace_reason" value="电话停机或关机" type="checkbox"></span>
                            <span class="gencuur"><font>现在正忙稍后再打</font><input name="trace_reason" value="现在正忙稍后再打" type="checkbox"></span>
                            <span class="gencuur"><font>直接挂断电话</font><input name="trace_reason" value="直接挂断电话" type="checkbox"></span>
                            <span class="gencuur"><font>需要考虑一下</font><input name="trace_reason"  value="需要考虑一下" type="checkbox"></span>
                        </li>
                        <li class="clearfix">
                            <span>其他原因</span>
                            <input type="hidden" id="trace_reason" value="">
                            <textarea id="trace_remark" class="remark" name="trace_other_reason"></textarea>
                        </li>
                        <li class="clearfix">
                            <span>下次跟踪时间</span>
                            <input type="text" value="" id="next_trace_time" name='next_trace_time' class="xiaci" placeholder="请选择下次跟踪时间" readonly="">
                        </li>
                    </ul>
                </div>
                <div class="yongBtn">
                    <input type="submit" value="确认" class="queding continue_trace"/>
                    <input class="quxiao" type="submit" value="返回" onclick="history.back();">
                </div>
            </div>
            <div class="yuList" style="display: none;">
                <div class="xuanzhe1" style="background: none;border:none;margin:0;">
                    <ul>
                        <li class="clearfix">
                            <span>*备注：</span>
                            <textarea id="failed_remark" class="remark" name="failed_remark"></textarea>
                        </li>
                    </ul>
                    <!--<input type="hidden" id="reserve_remark" name="reserve_remark" value="">-->
                </div>
                <div class="yongBtn">
                    <input type="submit" value="确认" class="queding not_sell"/>
                    <input class="quxiao" type="submit" value="返回" onclick="history.back();">
                </div>
            </div>
        </div>
    </div>
    <div class="clear"></div>
</div>
<style>
    .mianR .cuoshang-titler{ display: block; text-align: left;color:#333;font-size:16px;padding:10px 0 10px 12px;}
    .yuyue span{float: left;width:120px; text-align: left; display: block;color:#666;font-size:14px;}
    .negotiation{width:760px;display: block;border:solid 1px #ccc;margin:30px 0 0 30px;padding:20px 20px 0 20px; position: relative;}
    .negotiation2{margin:10px 0 0 30px;padding:20px 20px 50px 20px; position: relative;}
    .negotiation h4{ position: absolute;color:#20ab4f;top:-15px;left:30px;font-size:14px;width:90px; text-align:center;display: block;height: 30px; line-height: 30px; background:#fff;}
    .negotiation span,.negotiation2 span{ display: block;float: left;height:28px; line-height: 28px;margin-right:30px;color:#333;}
    .negotiation span input{ text-align: center;height:26px; line-height: 26px;width:180px;font-size:12px;}
    .negotiation span i{ display: inline-block;padding-right:10px;}
    .negotiation em{height:50px; line-height: 50px; text-align: left;width:760px; display: block;color:#333;}
    .negotiation1{padding:10px 20px;}
    .negotiation1 em{height:30px; line-height: 30px; text-align: left;width:760px; display: block;color:#333;}
    .negotiation1 ul{padding-top:10px;}
    .negotiation1 ul li span{margin-right:10px;width:80px; text-align: right;}
    .negotiation1 ul li .menDao{width:200px; text-align: left;}
    .negotiation1 ul li .menDao a{display: block;background: #cecece;color: #303030;float: left;padding: 0 10px;
        text-align: center;height: 20px;line-height: 20px;cursor: pointer;margin-top:5px;}
    .negotiation1 ul li{  display: block;text-align: left;line-height: 24px;margin-bottom: 10px;}
    .negotiation1 ul li .xiangDi{width:300px;height: 24px;line-height: 24px;border: solid 1px #dadada; text-align: center;}
    .negotiation1 ul li textarea{width:700px;border: solid 1px #dadada;height: 100px;resize:none;padding:5px;}
    .consult_remark{width:715px;border: solid 1px #dadada;height: 60px;resize:none;padding:5px;float: left;}
    .negotiation1 ul li .menDao .menHover{background: #20ab4f;color: #fff;}
    .negotiation1 ul li .xiaci{background: rgba(0, 0, 0, 0) url("{:get_style_cdnurl()}paimai/yunying/images/yun_tubiao3.jpg") no-repeat scroll 0 -201px; border: medium none;  cursor: pointer;  height: 24px;  line-height: 24px;  padding-right: 30px;  text-align: center;  width: 165px;}
    .shop_details .limit-change{float: left;height: 26px;width:202px;background: url("{:get_style_cdnurl()}paimai/yunying/images/sanjiao.jpg") no-repeat scroll 180px 5px;
        border: solid 1px #d7d7d7;text-indent: 10px;margin-right: 10px;}
</style>

<script type="text/javascript">
    $(function(){
        //打款账号
        initAccount();
        $('.account ul li').on('click',function(){
            $(".account ul li").removeClass("accountCurrent");
            $(this).addClass("accountCurrent");
            $("#account_id").val($(this).attr('data-id'));
            $("#bank_name").val($(this).attr('data-bank-name'));
            $("#card_no").val($(this).attr('data-card-no'));
            $("#account_name").val($(this).attr('data-account-name'));
        });
        function initAccount(){
            var accountObj = $(".account ul li");
            var countAccount = accountObj.length;
            if(countAccount < 2){
                accountObj.addClass('accountCurrent');
                $("#account_id").val(accountObj.attr('data-id'));
                $("#bank_name").val(accountObj.attr('data-bank-name'));
                $("#card_no").val(accountObj.attr('data-card-no'));
                $("#account_name").val(accountObj.attr('data-account-name'));
            }
        }


        $("#reserve_time").ymdateplugin({
            showTimePanel: true,
            changeMonth: true,
            changeYear: true,
            gotoCurrent: true,
            ampm: true
        });

        $("#next_trace_time").ymdateplugin({
            showTimePanel: true,
            changeMonth: true,
            changeYear: true,
            gotoCurrent: true,
            ampm: true
        });

        $("#reserve_store").select2();
        $(".shop_details .limit-change").css("color","#333");
        $(".shop_details .limit-change").find("option").css("color","#333");
        $(".shop_details .limit-change").each(function() {
            $(this).change(function(){
                var selectIndex = $(this).get(0).selectedIndex;
                $(this).css("color","#333");
                $(this).find("option").css("color","#333");

            });
        });
        (function($){
            $(".negotiation1 ul li .menDao a").click(function(index){
                $(".negotiation1 ul li .menDao a").removeClass("menHover");
                $(this).addClass("menHover");
                var index=$(".negotiation1 ul li .menDao a").index(this);
                $(".store .detailed").eq(index).show().siblings().hide();
                if(index == 0){
                    $("#appointment").html("预约门店")
                }else{

                    $("#appointment").html("预约地址")
                }
            });
        })($)
        $("#fare,#subsidy").val("");
        $(".auction-price").text((parseInt($(".cuur-price").text())+parseInt($(".fare-price").text())).toFixed(2));
        $(".auction-price1").text((parseInt($(".cuur-price1").text())+parseInt($(".subsidy-price").text())).toFixed(2));
        
        //commssion_price
        var commssion_price = get_commssion_price($(".auction-price").text());
        $(".deal-price").text(parseInt(commssion_price).toFixed(2));

        $(".auction-price2").text((parseInt($(".cuur-price2").text())+parseInt($(".deal-price").text())+parseInt($(".deliver-price").text())).toFixed(2));

        $("#fare").blur(function(){
            var fare = $(this).val();
            if(fare == "" || parseInt(fare) == "NaN"){
                $(".fare-price").text('0.00');
            }else{
                var reg_fare = fare / 100;
                if (!/(^[0-9]\d*$)/.test(reg_fare)) {
                    shibai_alert('价格不正确,请输入整百的数字');
                    return false;
                }
                $(".fare-price").text(parseFloat(fare).toFixed(2));
            }
            $(".auction-price").text((parseInt($(".cuur-price").text())+parseInt($(".fare-price").text())).toFixed(2));
            var auction_price = $(".auction-price").text();
            $(".cuur-price1,.cuur-price2").text(auction_price);
            $(".deal-price").text(parseInt(get_commssion_price(auction_price)).toFixed(2));
            $(".auction-price1").text((parseInt($(".cuur-price1").text())+parseInt($(".subsidy-price").text())).toFixed(2));
            $(".auction-price2").text((parseInt($(".cuur-price2").text())+parseInt($(".deal-price").text())+parseInt($(".deliver-price").text())).toFixed(2));
        });
        $("#subsidy").blur(function(){
            var subsidy = $(this).val();
            var reg_subsidy = subsidy / 100;
            if(subsidy == "" || parseInt(subsidy) == "NaN"){
                $(".subsidy-price").text('0.00');
            }else{
                if (!/(^[0-9]\d*$)/.test(reg_subsidy)) {
                    shibai_alert('价格不正确,请输入整百的数字');
                    return false;
                }
                $(".subsidy-price").text(parseInt(subsidy).toFixed(2));
            }
            $(".auction-price1").text((parseInt($(".cuur-price1").text())+parseInt($(".subsidy-price").text())).toFixed(2));
        });
    });

    //consult
    $(".consult").on('click',function(){
        var order_id = '{$detail.order_id}';
        if (order_id == '') {
            shibai_alert('缺少必要参数，请联系管理员');
            return;
        }
        var owner_id = '{$detail.owner_id}';
        if (owner_id == '') {
            shibai_alert('缺少必要参数，请联系管理员');
            return;
        }
        var fare = $("#fare").val()?$("#fare").val():0;
//        if(fare == "") {
//            shibai_alert('第一名加价价格不能为空');
//            return false;
//        }
        var reg_fare = fare / 100;
        if (!/(^[0-9]\d*$)/.test(reg_fare)) {
            shibai_alert('第一名加价价格不正确');
            return false;
        }
        var subsidy = $("#subsidy").val()?$("#subsidy").val():0;
//        if(subsidy == "") {
//            shibai_alert('公司补贴价格不能为空');
//            return false;
//        }
        var reg_subsidy = subsidy / 100;
        if (!/(^[0-9]\d*$)/.test(reg_subsidy)) {
            shibai_alert('公司补贴价格不正确');
            return false;
        }
        /*if(fare <= 0 && subsidy <= 0){
            shibai_alert('公司补偿不能为空');
            return false;
        }*/

        var consult_remark = $("#consult_remark").val();
        var consult_price = $(".auction-price1").text();
        var car_source = $("#car_source").val();
        if(car_source == 2) {
            var service_method = $('#service_method').val();
            if(service_method == 3){
                var reserve_store = $("#reserve_store").val();
                if (reserve_store == 0 || reserve_store == '请选择门店') {
                    shibai_alert('请选择门店');
                    return;
                }
            }else if(service_method == 2){
                var addr_obj = addr.getarr();
                var reserve_province = (addr_obj.length > 0) ? addr_obj[0].code : '0';
                var reserve_city = (addr_obj.length > 0) ? addr_obj[1].code : '0';
                var reserve_area = (addr_obj.length > 0) ? addr_obj[2].code : '0';
                var reserve_address = $("#reserve_address").val();
                if(reserve_province == 0 || reserve_city == 0 || reserve_area == 0){
                    shibai_alert('请选择预约地址');
                    return;
                }
            }
            var reserve_time = $("#reserve_time").val();
            if (reserve_time == '' || reserve_time == '请选择预约时间') {
                shibai_alert('请选择预约时间');
                return;
            }
        }else{
            //判断是否选中
            if(!$(".account ul li").hasClass('accountCurrent')){
                shibai_alert('请选择打款账号');
                return;
            };
            var account_id = $("#account_id").val();
            var bank_name = $("#bank_name").val();
            var card_no = $('#card_no').val();
            var account_name = $("#account_name").val();
        }
        confirm_alert('<div>请您确认磋商结果是否正确？<br/>' +
                "车主成交价格<span style='color:red;'>" + consult_price  + '元</span></div>',
                confirm_consult);
        function confirm_consult() {
            $('.determine').click(function () {
                colse_hide();
                consult();
            });
        }
        function consult() {
            var params = {
                'order_id': order_id,
                'owner_id': owner_id,
                'consult_id': {$detail.consult_id},
                'dealer_id' : {$detail.dealer_id},
                'car_source' : car_source,
                'fare' : fare,
                'subsidy' : subsidy,
                'service_method': service_method,
                'reserve_province': reserve_province,
                'reserve_city': reserve_city,
                'reserve_area': reserve_area,
                'reserve_address': reserve_address,
                'reserve_store': reserve_store,
                'reserve_time': reserve_time,
                'consult_remark' : consult_remark,
                'account_id':account_id,
                'bank_name':bank_name,
                'card_no':card_no,
                'account_name':account_name
            };
            _myPost('/Consult/do_consult_deal',params);
        }
    });

    //re auction
    $('.reauction').on('click',function(){
        var order_id = '{$detail.order_id}';
        if (order_id == '') {
            shibai_alert('缺少必要参数，请联系管理员');
            return;
        }
        var owner_id = '{$detail.owner_id}';
        if (owner_id == '') {
            shibai_alert('缺少必要参数，请联系管理员');
            return;
        }
        var compensate = $('#compensate').val();
        var limit_change = $('.limit-change').val();
        var reauction_remark = $("#reauction_remark").val();
        confirm_alert('<div>请您确定重拍吗？<br/>' +
                "保留价<span style='color:red;'>" + compensate  + '元</span></div>',
                confirm_reauction);
        function confirm_reauction() {
            $('.determine').click(function () {
                colse_hide();
                re_auction();
            });
        }
        function re_auction(){
            var params = {
                'order_id': order_id,
                'owner_id': owner_id,
                'consult_id': {$detail.consult_id},
                'reserve_price': compensate,
                'last_transfer_limit': "{$detail.transfer_limit}",
                'transfer_limit': limit_change,
                'remark': encodeURIComponent(reauction_remark)
            }
            _myPost('/Consult/do_reauction',params)
        }
    });

    //continue trace
    $(".continue_trace").on('click',function(){
        var order_id = '{$detail.order_id}';
        if (order_id == '') {
            shibai_alert('缺少必要参数，请联系管理员');
            return;
        }
        var owner_id = '{$detail.owner_id}';
        if (owner_id == '') {
            shibai_alert('缺少必要参数，请联系管理员');
            return;
        }
        $("input[name='trace_reason']:checkbox").each(function () {
            if (this.checked == true) {
                $('#trace_reason').val(this.value);
                return false;
            } else {
                $('#trace_reason').val('');
            }
        });
        var trace_reason_selected = $('#trace_reason').val();
        var trace_other_reason = $("#trace_remark").val();
        var trace_reason = trace_reason_selected ? trace_reason_selected : trace_other_reason;
        if (trace_reason == '') {
            shibai_alert('请选择或输入继续跟踪原因');
            return;
        }
        var next_trace_time = $('input[name=next_trace_time]').val();
        if (next_trace_time == '' || next_trace_time == '请选择下次跟踪时间') {
            shibai_alert('请选择下次跟踪时间');
            return;
        }
        confirm_alert('<div style="color:red">确定继续跟踪吗？</div>', confirm_continue_trace);
        function confirm_continue_trace() {
            $('.determine').click(function () {
                colse_hide();
                continue_trace();
            });
        }
        function continue_trace(){
            var params = {
                'order_id': order_id,
                'owner_id': owner_id,
                'consult_id': {$detail.consult_id},
                'next_trace_time': next_trace_time,
                'next_trace_remark': encodeURIComponent(trace_reason)
            };
            _myPost('/Consult/do_continue_trace',params)
        }
    });

    //not sell
    $(".not_sell").on('click',function(){
        var order_id = '{$detail.order_id}';
        if (order_id == '') {
            shibai_alert('缺少必要参数，请联系管理员');
            return;
        }
        var owner_id = '{$detail.owner_id}';
        if (owner_id == '') {
            shibai_alert('缺少必要参数，请联系管理员');
            return;
        }
        var failed_remark = $('#failed_remark').val();
        if (failed_remark == '') {
            shibai_alert('请选择或输入不卖原因');
            return;
        }
        confirm_alert('<div style="color:red">确定不卖了吗？</div>', confirm_not_sell);
        function confirm_not_sell() {
            $('.determine').click(function () {
                colse_hide();
                not_sell();
            });

        }
        function not_sell() {
            var params = {
                'order_id': order_id,
                'owner_id': owner_id,
                'consult_id': {$detail.consult_id},
                'remark': encodeURIComponent(failed_remark)
            };
            _myPost('/Consult/do_not_sell',params)
        }
    });


    /**
     *  submit data
     * @param status
     */
    function submit_data(status){
        if(status == 1){            //磋商成功
            var car_source = $("#car_source").val();
            var fare = $("#fare").val();
            var subsidy = $("#subsidy").val();
            if(car_source == 2){

            }
            var params = {
                "fare" : fare,
                "subsidy" : subsidy,
                "dealer_id" : {$detail.dealer_id}
            }
        }else if(status == 2){      //重拍
        }else if(status == 3){      //继续跟踪
        }else if(status == 4){      //不卖
        }
    }

    function _myPost(url,PostData){
        $(".yunBei").css("display","block").unbind('click')
        $(".loading").fadeIn();
        $.post(url, PostData, function (data) {
            if(data.code != 200){
                $(".loading").fadeOut();
                $(".yunBei").css("display","none")
                shibai_alert(data.msg);
                return false;
            }
            btn_alert("操作成功", 2000, function () {
                window.location.href = document.referrer;
            });
        }, 'json')
    }

    /**
     * get commssion price
     * @param price
     */
    function get_commssion_price(price){
        var PERCENTAGE = "{$percentage}";
        var MIN_FEE = "{$min_fee}";
        var MAX_FEE = "{$max_fee}";
        var p = price * PERCENTAGE;
        if(p <= MIN_FEE){
            p = MIN_FEE;
        }else if(p >= MAX_FEE){
            p = MAX_FEE;
        }else{
            p = Math.round(p/100) * 100;
        }
        return p;
    }
</script>
<include file="Public/foot" />